<template>
  <el-row style="width:100%" type="flex" justify="space-between" align="middle">
    <el-col :span="20">{{ item.name }}</el-col>
    <el-col :span="4">
      <el-row type="flex">
        <el-col>{{ item.manager }}</el-col>
        <el-col>
          <el-dropdown>
            <span class="el-dropdown-link">
              操作<i class="el-icon-arrow-down el-icon--right" />
            </span>
            <el-dropdown-menu slot="dropdown">
              <!-- 组件的点击原生dom需要click.native否则默认因为是父组件道德自定义事件
                   每次点击对应的行可以拿到这一行节点的数据然后传递给父组件 -->
              <el-dropdown-item @click.native="$emit('show-dailog',item)">添加子部门</el-dropdown-item>
              <el-dropdown-item v-if="!isHeader" @click.native="$emit('show-dailog',item,'edit')">编辑部门</el-dropdown-item>
              <el-dropdown-item v-if="!isHeader" @click.native="$emit('del',item)">删除部门</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </el-col>
      </el-row>
    </el-col>
  </el-row>
</template>

<script>
export default {
  props: {
    item: {
      type: Object,
      default: () => {}
    },
    isHeader: {
      type: Boolean,
      default: false
    }
  }
}
</script>

<style>

</style>
